/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */

#include <uservice/eventid.h>
#include <uservice/uservice.h>

#include "app_main.h"
#include "app_sys.h"
#include "app_init.h"
#include "combo_net.h"
#include "vendor.h"
#include "device_state_manger.h"
#include "smart_outlet.h"
#include "msg_process_center.h"
#include "property_report.h"

static aos_task_t task_key_detect;
static aos_task_t task_msg_process;
static aos_task_t task_property_report;
static aos_task_t task_reboot_device;

int main()
{
    board_base_init();
    board_yoc_init();

    LOGD(TAG, "%s\n", aos_get_app_version());

    aos_kv_setint(KV_WIFI_EN, 1);

    event_service_init(NULL);

    app_sys_init();

    aos_loop_init();

    app_cli_reg_cmds();

    app_network_init();

    vendor_product_init();
#if defined(APP_FOTA_EN) && APP_FOTA_EN
    app_fota_init();
#endif

    init_awss_flag();
    aos_task_new_ext(&task_key_detect, "detect key pressed", key_detect_event_task, NULL, 1024,
                     AOS_DEFAULT_APP_PRI);

    init_msg_queue();
    aos_task_new_ext(&task_msg_process, "cmd msg process", msg_process_task, NULL, 1024,
                     AOS_DEFAULT_APP_PRI - 1);
#ifdef REPORT_MULTHREAD
    aos_task_new_ext(&task_property_report, "property report", process_property_report_task, NULL,
                     2048, AOS_DEFAULT_APP_PRI);
#endif
    //     check_factory_mode();

    aos_loop_run();

    return 0;
}
